﻿using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MxWeiXinPF.Common;
using MxWeiXinPF.WeiXinComm;

namespace MxWeiXinPF.Web.shop
{
    public partial class qrcodepic : MxWeiXinPF.Web.UI.UserPage
    {
        public string carturl = "";
        private WeiXinCRMComm cpp = new WeiXinCRMComm();
        public string headimg = "";
        private int id = 0;
        protected Image img;
        public string indexurl = "";
        public string nickname = "";
        public string qrcodeurl = "";
        public string url = "";
        public string userinfourl = "";
        public string categoryurl = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                MxWeiXinPF.BLL.wx_dt_user_BaseData data = new MxWeiXinPF.BLL.wx_dt_user_BaseData();
                base.wid = MyCommFun.RequestInt("wid");
                base.openid = MyCommFun.RequestOpenid();
                this.shopid = MyCommFun.RequestInt("shopid");
                this.indexurl = string.Concat(new object[] { "index.aspx?wid=", base.wid, "&openid=", this.openid, "&shopid=", shopid });
                this.carturl = string.Concat(new object[] { "cart.aspx?wid=", base.wid, "&openid=", this.openid, "&shopid=", shopid });
                this.userinfourl = string.Concat(new object[] { "userinfo.aspx?wid=", base.wid, "&openid=", this.openid, "&shopid=", shopid });
                this.categoryurl = MyCommFun.urlAddOpenid("/shop/category.aspx?wid=" + base.wid + "&shopid=" + shopid, base.openid);
                MxWeiXinPF.Model.users modelByOpenID = new MxWeiXinPF.Model.users();
                modelByOpenID = data.GetModelByOpenID(base.openid);
                if (modelByOpenID != null)
                {
                    this.id = modelByOpenID.id;
                }
                string str = @"Upload\users\";
                string path = string.Concat(new object[] { HttpRuntime.AppDomainAppPath, str, base.wid, @"\", this.id, @"\" });
                string filename = path + "pic.jpg";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                string webSite = string.Concat(new object[] { MyCommFun.getWebSite(), "/shop/userqrcodepic.aspx?wid=", base.wid, "&openid=", base.openid });
                try
                {
                    GetImage image = new GetImage(webSite, 0x133, 580, 360, 720);
                    image.GetBitmap().Save(filename, ImageFormat.Jpeg);
                    this.img.ImageUrl = string.Concat(new object[] { "../upload/users/", base.wid, "/", this.id, "/pic.jpg" });
                }
                catch (Exception exception)
                {
                    base.Response.Write(exception.Message);
                }
            }
            catch (Exception ex)
            {

            }
        }
    }
}